const path=require('path');
const fs=require('fs');

const record_log=(req,res,next)=>{
    let visit_log=`${new Date().toLocaleString()} ${req.method} ${req.path}\n`;
    fs.appendFile(path.join(__dirname,'../log.txt'),visit_log,(err)=>{
        if(err) return console.log('录入日志出错');
        console.log('日志录入完成');
    });
    next();
}

module.exports=record_log;